//
//  YKUserViewController.m
//  yuke
//
//  Created by Dejun Liu on 15/1/5.
//  Copyright (c) 2015年 juwan. All rights reserved.
//

#import "YKUserViewController.h"
#import "YKUserTableViewCell.h"

@interface YKUserViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) NSArray *listData;

@end

@implementation YKUserViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"我的";
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64-49) style:UITableViewStyleGrouped];
    [self.view addSubview:self.tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView registerNib:[UINib nibWithNibName:@"YKUserTableViewCell" bundle:nil] forCellReuseIdentifier:@"Cell"];
    self.tableView.tableHeaderView = self.tbHeader;
    
    self.listData = @[@[@"我的消息",@"我的订单"],@[@"关于我们",@"检查更新",@"意见反馈"]];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [[self.listData objectAtIndex:section] count];;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 41.0f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *txt = [[self.listData objectAtIndex:indexPath.section]objectAtIndex:indexPath.row];
    
    YKUserTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.textLabel.textColor = [UIColor colorWithHex:0x313131];
    cell.topLine.hidden = YES;
    cell.centerLine.hidden = YES;
    cell.bottomLine.hidden = YES;
    
    if (indexPath.row == 0) {
        cell.topLine.hidden = NO;
        cell.centerLine.hidden = NO;
    }
    else if (indexPath.row == [[self.listData objectAtIndex:indexPath.section] count]-1) {
        cell.bottomLine.hidden = NO;
    }else
    {
        cell.centerLine.hidden = NO;
    }
    
    
    cell.textLabel.text = txt;
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    DLog(@"did selected");
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
